/*
 * Copyright 2011 Angel Sanadinov
 *
 * This file is part of VBox WMI.
 *
 * VBox WMI is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * VBox WMI is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with VBox WMI.  If not, see <http://www.gnu.org/licenses/>.
 */

package Managers.Utilities;

import Beans.Requests.RequestBean;
import Beans.Responses.ResponseBean;

/**
 * A wrapper class for related request and response object.
 *
 * @see RequestBean
 * @see ResponseBean
 *
 * @author Angel Sanadinov
 */
public class RequestResponseWrapper
{
    private RequestBean request;    //request object
    private ResponseBean response;  //response object to the request
    private boolean isNewMessage;   //denotes whether this is a newly added request/response

    /**
     * Constructs the wrapper with the supplied data.
     *
     * @param request the request object
     * @param response the response object associated with the request
     */
    public RequestResponseWrapper(RequestBean request, ResponseBean response)
    {
        this.request = request;
        this.response = response;
        this.isNewMessage = true;
    }

    /**
     * Retrieves the request object.
     *
     * @return the request object
     */
    public RequestBean getRequest()
    {
        return request;
    }

    /**
     * Retrieves the response object associated with the request.
     *
     * @return the response object
     */
    public ResponseBean getResponse()
    {
        return response;
    }

    /**
     * Returns whether this object represents a newly added request/response pair.
     *
     * @return <code>true</code> if the pair is new or <code>false</code> otherwise
     */
    public boolean isNewMessage()
    {
        return isNewMessage;
    }

    /**
     * Marks the request/response pair as read (old).
     */
    public void markAsRead()
    {
        isNewMessage = false;
    }
}
